
/**
 * 处理未捕获的异常，在exe中，如遇到报错，不会直接闪退，方便查看报错。
 */
process.on('uncaughtException', (err) => {  
  console.error('发生了未处理的异常:', err);  
  process.stdin.setRawMode(true);
  process.stdin.resume();
  process.stdin.on('data', process.exit.bind(process, 0));
});

// ES6 code  测试

class User {  
  constructor(name, age) {  
      this.name = name;  
      this.age = age;  
  }  

  async getUserInfo() {  
      return new Promise((resolve) => {  
          setTimeout(() => {  
              resolve(`User: ${this.name}, Age: ${this.age}`);  
          }, 1000);  
      });  
  }  
}  

const users = [  
  new User('Alice', 30),  
  new User('Bob', 25),  
  new User('Charlie', 35),  
];  

const displayUserInfo = async () => {  
  for (const user of users) {  
      const info = await user.getUserInfo();  
      console.log(info);  
  }  
};  

displayUserInfo();  